package com.gegao.somethinginteresting.utils;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Environment;

/**
 * Created by liuchenghui on 2016/03/15.
 */
public class Apputils {

    /**
     * @param context 上下文
     * @return apk包名
     */
    public static String getPackegName(Context context) {
        String packageName = "";
        PackageManager pm = context.getPackageManager();
        PackageInfo info = pm.getPackageArchiveInfo(Environment.getExternalStorageDirectory() + "/TianjinPlugin3.apk", PackageManager.GET_ACTIVITIES);
        ApplicationInfo appInfo = null;
        if (info != null) {
            appInfo = info.applicationInfo;
            packageName = appInfo.packageName;
        }
        return packageName;
    }
}
